i = 0
j = 0
a = 1
n = int(input())
if(n % 4 != 0):
    print("Wrong number")
else:
    b = [[0 for i in range(n)]for j in range(n)]
    while(a != n*n+1):
        if(i % 4 == j % 4 or i % 4+j % 4 == 3):
            b[i][j] = n*n+1-a
        else:
            b[i][j] = a
        if(j == n-1):
            i += 1
            j = 0
        else:
            j += 1
        a += 1
    for i1 in range(n):
        for j1 in range(n):
            print("%4d" % b[i1][j1],end='')
        print()
